/**
 * ReportGear(2011)
 */
package com.reportgear.report.print;

import java.util.Iterator;

/**
 * 记录页面的其实单元格与终止单元格索引
 * 
 * @version 1.0 2011-3-23
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class FT implements Iterable<Integer> {
	public int from;
	public int to;

	public FT(int from, int to) {
		this.from = from;
		this.to = to;
	}

	public int getFrom() {
		return this.from;
	}

	public void setFrom(int from) {
		this.from = from;
	}

	public int getTo() {
		return this.to;
	}

	public void setTo(int to) {
		this.to = to;
	}

	/**
	 * @return 元素数量
	 */
	public int getSize() {
		return this.to - this.from;
	}

	@Override
	public String toString() {
		return this.from + " 到 " + this.to;
	}

	@Override
	public Iterator<Integer> iterator() {
		return new Iterator<Integer>() {
			private int ptr = from;

			@Override
			public boolean hasNext() {
				return this.ptr != to;
			}

			@Override
			public Integer next() {
				return this.ptr++;
			}

			@Override
			public void remove() {

			}
		};
	}
}
